<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>unused</title>
    <style>
      /*
        configure CSS (inline or linked) validly to your liking
      */
    </style>
  </head>
  <body>
    <!-- construct HTML validly to your liking -->
    <script>
      var pluginHost;
      var mapDocument = null;   // only when you wanted such
      var mapsVersion;
      
      
      // listen for callbacks from configured toolbar items or
      // the cleanup command when the user disables your plugin
      // evaluate the version message, see documentation
      onmessage = event => {
        let message = event.data.pluginParent;
        if(message) {
          switch(message.cause) {
            case "callback":
              return handleEvents(message.cargo);
            case "cleanup":
              return stop();
            case "commence":
              pluginHost = event.source;
              return start();
            default:
          }
        }
      };
      
      // event handler
      function handleEvents(cargo) {
        switch (cargo.id) {
          case "an identificator of your choosing for you to be able to differentiate event handler returns":
            switch (cargo.event) {
              case "event type":
                if(confirm("Look! What do you want? My value is always \"" + cargo.value + "\".")) {
                  // call JS function
                  alert("\"" + cargo.data.join(", ") + "\" are the value of the properties of the event object I configured to get returned.");
                }
                break;
              default:
            }
            break;
          default:
        }
      }
      
      // the cleanup function
      function stop() {
        // revert any changes by the plugin eg. to the map DOM,
        // .5 seconds are available for any asynchronity
      }
      
      // all pluginhost initialisation has occurred,
      // all information which ought to be provided
      // is provided
      function start() {
        // if you expect map access
        if(mapDocument !== null) {
          // this version of this plugin is not intended for
          // versions of the map other than 1
          // ask user about risking letting continue execution
          if(mapsVersion !== 1 && !confirm("continue?")) {
            return pluginHost.postMessage({"throw": "any text of \"throw\" is shown to the user as reason for aborting the plugin's execution"}, "*");
          }
          // code
        } else {
          pluginHost.postMessage({"throw": "any text of \"throw\" is shown to the user as reason for aborting the plugin's execution"}, "*");
        }
      }
      
      // provide this if you have requested map access.
      // It will be delivered the map iframe's document object
      // and the "map version", see documentation.txt .
      function setMapDocument(iframeDocument, mapVersion) {
        mapDocument = iframeDocument;
        mapsVersion = mapVersion;
      }
      
      // code JS (inline or outsourced) validly to your liking
    </script>
  </body>
</html>